package com.findme.securitydb.controller;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author 江南一点雨
 * @Site www.javaboy.org 2019-08-11 14:36
 */
@RestController
public class HelloController {

    @GetMapping("hello")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "bid", value = "bid"),
            @ApiImplicitParam(name = "bookUrl", value = "图片URL"),
            @ApiImplicitParam(name = "type", value = "1 删除其他图片 2删除实例图片"),

    })
    public String hello() {
        return "hello";
    }

    @GetMapping("/db/hello")
    public String db() {
        return "hello db";
    }

    @GetMapping("/admin/hello")
    public String admin() {
        return "hello admin";
    }

    @GetMapping("/user/hello")
    public String user() {
        return "hello user";
    }

    @GetMapping("/login")
    public String login() {
        return "please login!";
    }


    //查询所有员工返回列表页面
    @GetMapping("/emps")
    public String list(Model model) {
        List<JSONObject> jsonObjectlist2 = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("xq", "当代国际2");
            jsonObject.put("fsh", "2020年6月18日2");
            jsonObject.put("gzlx", "不知道");
            jsonObject.put("cbsj", i);
            jsonObjectlist2.add(jsonObject);
        }
        //放在请求域中
        model.addAttribute("emps", jsonObjectlist2);
        // thymeleaf默认就会拼串
        // classpath:/templates/xxxx.html
        return "demo";
    }
}
